package cn.taobaoke.restful.domain;

import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;

/**
 * NoticeRepository类.
 * +----------------------------------------------------------------------------------+
 * |类名称: NoticeRepository                                                                         |
 * |创建时间: 5/6/17                                                                               |
 * |功能简介:                                                                                       |
 * |参考链接:                                                                                       |
 * +-----------------------------------------------------------------------------------------------+
 *
 * @author luch
 */
@Repository
public interface NoticeRepository extends JpaRepository<NoticeEntity, Long> {

    Optional<NoticeEntity> findByIdAndDomainId(Long id, Long domainId);

    List<NoticeEntity> findAllByDomainId(Long domainId, Sort sort);

    @Transactional
    void deleteByIdAndDomainId(Long id, Long domainId);
}
